{% extends "base.html" %}

{% block title %}字典项 - 网站管理后台{% endblock %}

{% block content %}
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
    <h1 class="h2">字典项</h1>
    <div class="btn-toolbar mb-2 mb-md-0">
        <div class="btn-group me-2">
            <a href="{{ url_for('web.add_dictionary_item', dictionary_id=dictionary[0]) }}" class="btn btn-sm btn-outline-secondary">
                <i class="fas fa-plus"></i> 添加字典项
            </a>
        </div>
    </div>
</div>

<div class="row mb-3">
    <div class="col-md-6">
        <div class="card">
            <div class="card-header">
                <h5>字典信息</h5>
            </div>
            <div class="card-body">
                <p><strong>编码:</strong> {{ dictionary[1] }}</p>
                <p><strong>名称:</strong> {{ dictionary[2] }}</p>
                <p><strong>分类:</strong> {{ dictionary[3] or '-' }}</p>
                <p><strong>描述:</strong> {{ dictionary[4] or '-' }}</p>
            </div>
        </div>
    </div>
</div>

<div class="table-responsive">
    <table class="table table-striped table-hover">
        <thead>
            <tr>
                <th>ID</th>
                <th>编码</th>
                <th>标签</th>
                <th>值</th>
                <th>描述</th>
                <th>排序</th>
                <th>状态</th>
                <th>创建时间</th>
            </tr>
        </thead>
        <tbody>
            {% for item in items %}
            <tr>
                <td>{{ item[0] }}</td>
                <td>{{ item[2] }}</td>
                <td>{{ item[3] }}</td>
                <td>{{ item[4] or '-' }}</td>
                <td>{{ item[5] or '-' }}</td>
                <td>{{ item[6] }}</td>
                <td>
                    {% if item[7] == 1 %}
                        <span class="badge bg-success">启用</span>
                    {% else %}
                        <span class="badge bg-secondary">禁用</span>
                    {% endif %}
                </td>
                <td>{{ item[8] }}</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</div>

<div class="mt-3">
    <a href="{{ url_for('web.data_dictionaries') }}" class="btn btn-secondary">返回数据字典</a>
</div>
{% endblock %}